package engine

import (
	"log"
)

type SimpleEngine struct {

}

func (e SimpleEngine) Run (seeds ...Request){
	var requests []Request
	for _,r := range seeds {
		requests = append(requests, r)
	}

	for len(requests) > 0{
		r := requests[0]
		requests = requests[1:]

		// 编码转换失败就直接跳过 进行下一个
		parserResult, err := worker(r)
		if err != nil {
			continue
		}

		// 将parserResult中的requests都放入 requests,无限请求下去
		requests  = append(requests, parserResult.Requests...)

		for _,item := range parserResult.Items {
			log.Printf("Got item: %v",item)
		}
	}

}

